#coding=utf8
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import DataRequired, ValidationError

class LoginForm(FlaskForm):
	admin_user = StringField(
		label=u'管理员账号',
		validators=[
			DataRequired(u'管理员账号不能为空')
		],
		description=u'管理员账号）',
		render_kw={"class": "form-control", "placeholder": u"单行输入", "id": "stu_num"}
	)
	password = PasswordField(
		label=u'密码',
		validators=[
			DataRequired(u'密码不能为空')
		],
		description=u'密码',
		render_kw={"class": "form-control", "placeholder": u"请输入密码"}
	)
	submit = SubmitField(
		u'登录',
		render_kw={"class": "btn btn-success", "style": "background: #007bff"}
	)


	def validate_password(self, field):
		if self.admin_user.data!='tri_admin' or field.data!='2018':
			raise ValidationError(u'用户名或密码错误，请重新登录')
